<?php
if (!defined("IN_OP"))
{
    exit("You can't access this file directly...");
}
$ui = new UI();
include( "member/news.php" );
$tpl = new Template2();
$conf = new Config();
$lotto_id = 0;
if (isset($_GET['lotto_id']))
{
    $lotto_id = intval($_GET['lotto_id']);
}
if ($lotto_id == 0)
{
    $rs = getdb("select id from lotto where open>='" . date("Y-m-d") . "' order by open");
    if ($rs->eof)
    {
        $ui->showErrorPage("<p>目前没有可以下注期数！</p>");
        exit();
    }
    $lotto_id = $rs->f['id'];
}
if ($curruser['enabled'] == 0 || $curruser['enabled'] == 2)
{
    $ui->showErrorPage("<p class=error>帐号已被暂停使用</p>");
    exit();
}
$rs = getdb("select * from lotto where id = " . $lotto_id);
if ($rs->eof)
{
    $ui->showErrorPage("<p>错误！</p>");
    exit();
}
$open = $rs->f['open'];
$round = $rs->f['round'];
$rs1 = getdb("select id from lotto where open > '{$open}' order by open");
$next_id = $rs1->f['id'];
$rs1 = getdb("select id from lotto where open < '{$open}' order by open desc");
$prev_id = $rs1->f['id'];
$pnStr = "";
if (0 < $prev_id)
{
    $pnStr .= "<a href=\"?op=agent&fp=" . $fp . "&lotto_id=" . $prev_id . "\">&lt;&lt;&lt; 上一期</a>";
}
$pnStr .= " :: [ 下注期数：<b>" . d3($round) . "</b>  开奖日：<b>" . $open . "</b> ] :: ";
if (0 < $next_id)
{
    $pnStr .= "<a href=\"?op=agent&fp=" . $fp . "&lotto_id=" . $next_id . "\">下一期 &gt;&gt;&gt;</a>";
}
if (isset($_GET['cmd']) && $_GET['cmd'] == "stopnow1")
{
    $conf->set("linebet", date("Hi", systime() - 60));
    $conf->set("waitbet", date("Hi", systime() - 60));
}
$betmin = intval($conf->get("betmin"));
$stopbet = $conf->get("linebet");
$t1 = strtotime($open . " " . $stopbet);
$tpl->Set("timestap", $t1 - systime());
$tpl->Set("fp", $fp);
$tpl->Set("lotto_id", $lotto_id);
$dt = date("Y-m-d");
if (!isset($_SESSION['split']))
{
    $_SESSION['split'] = 1;
}
$split = $_SESSION['split'];
if (isset($_GET['split']))
{
    $split = intval($_GET['split']);
    $_SESSION['split'] = $split;
}
$tpl->set("split", $split);
if ($split == 1)
{
    $tpl->set("td0", "td3");
}
else
{
    $tpl->set("td0", "td0");
}
$percurl = preg_replace("/split=\\d?/", "", $_SERVER['REQUEST_URI']);
$list = "&nbsp;&nbsp;&nbsp;成数：<select onchange=\"location.replace('" . $percurl . "&split=' + this.value)\">";
$list .= "<option value=0";
if ($split == 0)
{
    $list .= " selected";
}
$list .= ">全部<option value=1";
if ($split == 1)
{
    $list .= " selected";
}
$list .= ">成数</select>";
$tpl->set("bypercent", $list);
$tpl->set("split_id", $split);
$tpl->set("dt", $dt);
$tpl->set("phptime", systime());
$disk = isset($_GET['disk']) ? max(0, min(4, intval($_GET['disk']))) : 0;
$diskurl = preg_replace("/disk=\\d?/", "", $_SERVER['REQUEST_URI']);
$disks = "&nbsp;&nbsp;&nbsp;盘类：<select name=disk onchange=\"location.replace('" . $diskurl . "&disk='+this.value)\">";
$disks .= "<option value=0" . ( $disk == 0 ? " selected" : "" ) . ">全部";
$disks .= "<option value=1" . ( $disk == 1 ? " selected" : "" ) . ">A 盘";
$disks .= "<option value=2" . ( $disk == 2 ? " selected" : "" ) . ">B 盘";
$disks .= "<option value=3" . ( $disk == 3 ? " selected" : "" ) . ">C 盘";
$disks .= "<option value=4" . ( $disk == 4 ? " selected" : "" ) . ">D 盘";
$disks .= "</select>";
$tpl->set("disks", $disks);
$tpl->set("disk_id", $disk);
include_once( "class_6h/class.menu.php" );
$fieldArr = array("lotto_id" => $lotto_id, "split_id" => $split, "disk_id" => $disk, "bypercent" => $list, "disks" => $disks, "pnStr" => $pnStr);
$onlineMenu = new menu_6h(0, $fieldArr);
$selectid = getvar("select") == "" ? 0 : getvar("select");
$menuList = $onlineMenu->getMenu($selectid);
$tpl->set("menuList", $menuList);
$tpl->set("selectid", $selectid);
unset($onlineMenu);
?>